<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-color: black;
        }
        .box {
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 100px auto;
            perspective: 800px;
        }
        ul li {
            position: relative;
            height: 100px;
            width: 100px;
            transform-style: preserve-3d;
            transition: all 1s;
        }
        .span1 {
            position: absolute;
            display: block;
            height: 100px;
            width: 100px;
            background-color: red;    
            z-index: 1;
        }
        .span2 {
            position: absolute;
            display: block;
            height: 100px;
            width: 100px;
            background-color: blue;
            z-index: 0;
            transform: translateY(50px) rotateX(90deg);
            /* transform: rotateX(90deg); */
            /* transform-origin: top center; */
        }
        li:hover {
            transform: rotateX(90deg);
        }

    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li>
                <span class="span1"></span>
                <span class="span2"></span>
            </li>
        </ul>
    </div>
</body>
</html>